<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>跨爬行为详情</title>

		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/app.css" />
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
		<link href="css/new_file.css" rel="stylesheet" type="text/css">

		<script src="js/mui.min.js"></script>
		<script src="js/mui.picker.min.js"></script>

		<script src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script src="js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>

	</head>

	<body>

		<div class="head-zhjf">
			<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="fanhuizhuan()">
			<div class="search-tjxq">
				<input id="searchData" class="tjxq-search-btn" type="text" value="请输入奶牛耳号" onfocus="if(value==defaultValue){value='';this.style.color='#ffffff'}" onblur="if(!value){value=defaultValue;this.style.color='#ffffff'}" style="background:none;color: rgb(255,255,255);">
				<img class="sousuo-tjxq" src="images/serach-w.png" onclick="findsearchCow()">
			</div>
		</div>
		<div class="liebiao-div" id="tableCellID" style="background-color: white;">
		</div>
		<!-- 疑似发情判断弹框-->
		<div class="nzlb_tc" style="display: none;" id="lu_pan0">
			<div class="nzlb_tc_nr" >
				<div class="nzlb_tc_nr_bt" id="lu_pan_ob">12643 判定揭发情况</div>
				<div class="nzlb_tc_nr_an">
					<a class="nzlb_tc_nr_an_a" cow_id="" id="lu_pan_y" onclick="ShowTangKang(1)">判定发情</a>
					<a class="nzlb_tc_nr_an_a" cow_id="" id="lu_pan_n" onclick="WPReason(2)">判定未发情</a>
				</div>
				<div class="nzlb_tc_nr_qx" onclick="hideysfaq()">取消</div>
			</div>
		</div>
		<!--配种情况弹框-->
		<div class="nzlb_tc" style="display: none;" id="lu_pan1">
			<div class="nzlb_tc_nr" >
				<div class="nzlb_tc_nr_bt" id="lu_pan_ob1">12643 判定揭发情况</div>
				<div class="nzlb_tc_nr_an">
					<a class="nzlb_tc_nr_an_a" style="width: 60%;margin-top: 2px;" cow_id=""  onclick="HeadOestrusInterface2(this)">待配</a>
					<a class="nzlb_tc_nr_an_a" style="width: 60%;margin-top: 2px;" cow_id=""  onclick="ShowTangKang(2)">配种</a>
					<a class="nzlb_tc_nr_an_a" style="width: 60%;margin-top: 2px;" cow_id=""  onclick="WPReason(1)">未配种</a>
					
				</div>
				<div class="nzlb_tc_nr_qx" onclick="hideysfaq()">取消</div>
			</div>
		</div>
		<!-- 配种精子选择-->
		<div class="nzlb_tc" style="display: none;" id="lu_pan2">
			<div class="nzlb_tc_nr" >
				<div class="nzlb_tc_nr_bt" id="lu_pan_ob2" >12643 判定揭发情况</div>
				<div class="nzlb_tc_nr_an">
					<a class="nzlb_tc_nr_an_a" cow_id=""  onclick="HeadOestrusInterface2(this)">常规冻精</a>
					<a class="nzlb_tc_nr_an_a" cow_id=""  onclick="HeadOestrusInterface2(this)">性控冻精</a>
				</div>
				<div class="nzlb_tc_nr_qx" onclick="hideysfaq()">取消</div>
			</div>
		</div>
		<!--未配种弹框-->
		<div class="nzlb_tc" style="display: none;" id="lu_pan3">
			<div class="nzlb_tc_nr" >
				<div class="nzlb_tc_nr_bt" id="lu_pan_ob3" >判定揭发情况</div>
				<div class="nzlb_tc_nr_an">
					<input id="iptext1" type="text" value="选择原因" style="width: 100%;text-align:center" readonly="readonly">
				</div>
				<div class="nzlb_tc_nr_qx"  style="width: 50%;float: left;background: #2d82ff;color: #fff" onclick="HeadOestrusInterface1(6)">确定</div>
				<div class="nzlb_tc_nr_qx"  style="width: 50%;float: right" onclick="hideysfaq()">取消</div>
			</div>
		</div>
		<!--未配原因-->
		<div class="nzlb_tc" style="display: none;overflow-y: scroll;z-index: 99;background-color: white;" id="lu_pan4">

		</div>
		<div class="nzlb_tc" style="display: none;" id="lu_pan5">
		</div>
		<!--撤回弹框-->
		<div class="nzlb_tc" style="display: none;" id="lu_pan6">
			<div class="nzlb_tc_nr" >
				<div class="nzlb_tc_nr_bt" >是否撤回</div>
				<div class="nzlb_tc_nr_qx"  style="width: 50%;float: left;background: #2d82ff;color: #fff"  cow_id="" id="lu_ch" onclick="returnJudge()">确定</div>
				<div class="nzlb_tc_nr_qx"  style="width: 50%;float: right" onclick="hideysfaq()">取消</div>
			</div>
		</div>
		<script>
			var pageNumber = 2;
			var times;
			var butStr = 0;
			var DetailsOfOestrusData = JSON.parse(localStorage.getItem('DetailsOfOestrusData'));

			console.log(DetailsOfOestrusData)
			var tableCellID = document.getElementById('tableCellID');
			//			wholeArr = bb.data;
			if(DetailsOfOestrusData.length != 20) {
				butStr = 1;
			}
			huitu();

			for(var i = 0; i < DetailsOfOestrusData.length; i++) {
				if(DetailsOfOestrusData[i].countDown != undefined) {
					resetTime('s'+DetailsOfOestrusData[i].cow_id, DetailsOfOestrusData[i].countDown);
				}
			}

			function FindACow() {
				mui.alert("设备未上线，无法预约找牛");
			}

			var cows;
			var time;
			var cowsID;
			(function($) {
				$.init();
				//					var resultss = $('#result')[0];
				var btns = $('.btn');
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var _self = this;
						var optionsJson = this.getAttribute('data-options') || '{}';
						var options = JSON.parse(optionsJson);
						var id = this.getAttribute('id');
						_self.picker = new $.DtPicker(options);
						_self.picker.show(function(rs) {

							console.log(rs.text);

							cowsID = id;
							console.log(cowsID);
							cows = id.substr(1);
							console.log(cows);
							time = rs.text;
							findCowBut();

							_self.picker.dispose();
							_self.picker = null;
						});
					}, false);
				});
			})(mui);

			function findCowBut() {
				var cowss = new Array();
				var str = $("#" + cowsID).html();
				console.log(str);
				if(str == "找牛") {
					cowss.push(cows);
					var keys = JSON.parse(localStorage.getItem('key'));
					var map = {};
					map.key = keys;
					map.cows = cowss;
					map.time = time;
					map.phoneType = "android";
					map.language = "zh";
					var jsonStr = JSON.stringify(map);
					console.log(jsonStr);
					showDialog();
					var ajaxTimeoutTest = $.ajax({
						type: "POST",
						url: url_prefix + "findCow",
						dataType: 'JSON',
						 timeout: 10000,
						data: {
							'request': encryptByDES(jsonStr)
						},
						success: function(data) {
							dismissDialog();
							var str1 = decryptByDESModeEBC(data["result"]); //解密
							var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
							var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
							var datas = JSON.stringify(str2); //转JSON字符串
							var aa = datas.replace(/\\n/g, " "); //去掉换行
							var objs = eval('(' + aa + ')');
							var bb = eval('(' + objs + ')');
							console.log(bb)
							if(bb.head.status == 1) {
								console.log(bb.data.returnList[0].Countdown)
								times = parseInt(bb.data.returnList[0].Countdown);
								resetTime(cowsID, times);
								//								window.location = "发情揭发.html";
							} else {

								mui.alert(bb.head.info);
							}
						},
						complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
							dismissDialog();
							if(status == 'timeout') { //超时,status还有success,error等值的情况
								ajaxTimeoutTest.abort();　　　　　
								mui.alert("网络请求超时...");　　　　
							}　　
						}
					});
				} else {
					mui.alert("已在找牛中。。。");
				}
			}

			var remark;
			var time;

			function OestrusDetermination(id) {
				console.log(id);
				console.log(DetailsOfOestrusData[id].result)
				if(DetailsOfOestrusData[id].result == "疑似发情") {
					document.getElementById("lu_pan_ob").innerHTML=DetailsOfOestrusData[id].overbit+"判定揭发情况";
					document.getElementById("lu_pan_ob1").innerHTML=DetailsOfOestrusData[id].overbit+"配种情况";
					document.getElementById("lu_pan_ob2").innerHTML=DetailsOfOestrusData[id].overbit+"配种精子选择";
					document.getElementById("lu_pan_ob3").innerHTML=DetailsOfOestrusData[id].overbit+"操作原因";
					document.getElementById("lu_pan_y").setAttribute("cow_id",id);
					ShowTangKang(0);
				}else if(DetailsOfOestrusData[id].result == "未发情"){
					mui.toast("该奶牛未发现发情症状");
				}else if(DetailsOfOestrusData[id].result == "确认发情"){
					mui.toast("该奶牛确认发情");
				}else if(DetailsOfOestrusData[id].result == "确认未发情"){
					document.getElementById("lu_ch").setAttribute("cow_id",id);
					ShowTangKang(6);
				}else if(DetailsOfOestrusData[id].result == "人工揭发发情"){
					mui.toast("该奶牛人工揭发发情");
				}else if(DetailsOfOestrusData[id].result == "同期发情"){
					mui.toast("该奶牛同期发情");
				}
				
			}
			//撤回判断
			function returnJudge() {
				var id=document.getElementById("lu_ch").attributes["cow_id"].nodeValue;
				var keys = JSON.parse(localStorage.getItem('key'));
				var map = {};
				map.key = keys;
				map.cowID = DetailsOfOestrusData[Number(id)]["cow_id"];//牛id
				map.result=DetailsOfOestrusData[Number(id)]["result"];//判定类型
				map.statetime=DetailsOfOestrusData[Number(id)]["statetime"];//操作时间
				map.ce_date=DetailsOfOestrusData[Number(id)]["ce_date"];//数据存储时间
				map.phoneType = "android";
				map.language = "zh";
				var jsonStr = JSON.stringify(map);
				var ajaxTimeoutTest = $.ajax({
					type: "POST",
					url: url_prefix + "returnjudge",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						debugger;
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							tjPregnancy();
						} else {
							mui.alert(bb.head.info);
						}
					},
					complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
						if(status == 'timeout') { //超时,status还有success,error等值的情况
							ajaxTimeoutTest.abort();
							mui.alert("网络请求超时...");
						}
					}
				});
			}
			function OestrusDetails(id) {
				var keys = JSON.parse(localStorage.getItem('key'));
				var map = {};
				map.key = keys;
				map.cowID = DetailsOfOestrusData[Number(id)]["cow_id"];
				map.date=JSON.parse(localStorage.getItem('paramsNameDate'));
				map.phoneType = "android";
				map.language = "zh";
				var jsonStr = JSON.stringify(map);
				var ajaxTimeoutTest = $.ajax({
					type: "POST",
					url: url_prefix + "oestrus",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							localStorage.setItem('OestrusDetailsData', JSON.stringify(bb.data));
							localStorage.setItem('Cow_Id', JSON.stringify(map.cowID));
							window.location = "发情详情.html";
						} else {
							mui.alert(bb.head.info);
						}
					},
					complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
						dismissDialog();
						if(status == 'timeout') { //超时,status还有success,error等值的情况
							ajaxTimeoutTest.abort();　　　　　
							mui.alert("网络请求超时...");　　　　
						}　　
					}
				});
			}

			function fanhuizhuan() {
				var type = JSON.parse(localStorage.getItem('DetailsType'));
				if (type==11||type==12||type==13||type==14){
					window.location.href = "首页.html";
					// shouye();
				} else {
					localStorage.setItem('ToChangeIntoNumber', JSON.stringify(0));
					localStorage.setItem('TurnOutNumber', JSON.stringify(0));
					emotionalSuccessRate();
				}
			}

			function resetTime(id, times) {  
				var timer = null;  
				var t = times; 
				console.log(t); 
				var h = 0; 
				var m = 0;  
				var s = 0; 
				h = parseInt(t / 3600)
				m = parseInt(t / 60 % 60);  
				m < 10 && (m = '0' + m);  
				s = Math.floor(t % 60);  
				function countDown() {   
					s--;   
					s < 10 && (s = '0' + s);  
					if(s.length >= 3) {  
						if(Number(m) == 0) {
							s = 59; 
							m = 59;   
							h = (Number(h) - 1);
						} else {
							s = 59;    
							m = (Number(m) - 1);
						}  
					}
					if(m < 10) {
						m = "0" + Number(m);
					}
					//					if(h.length >= 3) { 
					//						h = '0';    
					//						m = '00';    
					//						s = '00';    
					//						clearInterval(timer);   
					//					}   
					console.log(h + ":" + m + ":" + s); 
					console.log(id);
					$("#" + id).html(h + ":" + m + ":" + s); 
					if(s == '00' && m == '00' && h == '0') {
						clearInterval(timer);
						$("#" + id).html("已亮灯");
						return;
					}
				}  
				timer = setInterval(countDown, 1000);
			}

			//获取滚动条当前的位置 
			function getScrollTop() {
				var scrollTop = 0;
				if(document.documentElement && document.documentElement.scrollTop) {
					scrollTop = document.documentElement.scrollTop;
				} else if(document.body) {
					scrollTop = document.body.scrollTop;
				}
				return scrollTop;
			}

			//获取当前可视范围的高度 
			function getClientHeight() {
				var clientHeight = 0;
				if(document.body.clientHeight && document.documentElement.clientHeight) {
					clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
				} else {
					clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
				}
				return clientHeight;
			}

			//获取文档完整的高度 
			function getScrollHeight() {
				return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
			}
			window.onscroll = function() {
				if(getScrollTop() + getClientHeight() >= getScrollHeight()-2) { //ajax从这里开始
					if(butStr == 1) {
						mui.toast("没有更多数据了")
					} else {
						var type = JSON.parse(localStorage.getItem('DetailsType'));
						var keys = JSON.parse(localStorage.getItem('key'));
						var mapdate=JSON.parse(localStorage.getItem("paramsNameDate"));
						var map = {};
						map.key = keys;
						map.page = pageNumber;
						map.size = 20;
						map.date=mapdate;
						// if(type == 1 || type == 2 || type == 3) {
							var paramsName = JSON.parse(localStorage.getItem('paramsNameDate'))
							map.startDate = paramsName;
							map.endDate = paramsName;
						// }
						map.type = type;
						map.phoneType = "android";
						map.language = "zh";
						var jsonStr = JSON.stringify(map);
						console.log(jsonStr);
						showDialog();
						var ajaxTimeoutTest = $.ajax({
							type: "POST",
							url: url_prefix + "estrusList",
							dataType: 'JSON',
							 timeout: 10000,
							data: {
								'request': encryptByDES(jsonStr)
							},
							success: function(data) {
								dismissDialog();
								var str1 = decryptByDESModeEBC(data["result"]); //解密
								var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
								var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
								var datas = JSON.stringify(str2); //转JSON字符串
								var aa = datas.replace(/\\n/g, " "); //去掉换行
								var objs = eval('(' + aa + ')');
								var bb = eval('(' + objs + ')');
								if(bb.head.status == 1) {
									if(bb.data.length != 20) {
										butStr = 1;
									}
									if(bb.data.length == 0) {
										mui.toast("没有更多数据了");
									}
									for(var i = 0; i < bb.data.length; i++) {
										DetailsOfOestrusData.push(bb.data[i]);
									}
									pageNumber ++;
									huitu();
								} else {
									mui.alert(bb.head.info);
								}
							},
							complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
								dismissDialog();
								if(status == 'timeout') { //超时,status还有success,error等值的情况
									ajaxTimeoutTest.abort();　　　　　
									mui.alert("网络请求超时...");　　　　
								}　　
							}
						});
					}
				}
			}
	function dateTest(oldTimes1)
        {
            var d = new Date(oldTimes1);
            //alert(d.getDate() + " -- " + d.getDay());
            //alert(d.getTime());
            //设定的时间加上一个小时
            var end = new Date(d.getTime() + 16 * 60 * 60 * 1000);  
			var time = 	dateFormat(end,'MM-dd HH');
            return time;
			
        }
		
			function dateTest1(oldTimes1){
            var d = new Date(oldTimes1);
            //alert(d.getDate() + " -- " + d.getDay());
            //alert(d.getTime());
            //设定的时间加上一个小时
            var end = new Date(d.getTime() + 8 * 60 * 60 * 1000);  
			var time = 	dateFormat(end,'MM-dd HH');
            return time;
			
        }
		
		function dateFormat (date, format) {
            date = new Date(date);
            var o = {
                'M+' : date.getMonth() + 1, //month
                'd+' : date.getDate(), //day
                'H+' : date.getHours(), //hour
                'm+' : date.getMinutes(), //minute
                's+' : date.getSeconds(), //second
                'q+' : Math.floor((date.getMonth() + 3) / 3), //quarter
                'S' : date.getMilliseconds() //millisecond
            };

            if (/(y+)/.test(format))
                format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));

            for (var k in o)
                if (new RegExp('(' + k + ')').test(format)){
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
                }
            return format;
        }
			// function huitu() {
				//绘制单个div
				function setDiv(item, i) {
					console.log(DetailsOfOestrusData)
					var flag = item.result; 
					if(item.result == 0) {
						item.result = "未发情";
					} else if(item.result == 1) {
						item.result = "疑似发情";
					} else if(item.result == 2) {
						item.result = "确认发情";
					} else if(item.result == 3) {
						item.result = "确认未发情";
					} else if(item.result == 4) {
						item.result = "人工揭发发情";
					} else if(item.result == 5) {
						item.result = "同期发情";
					}
					var mating_status='';
					if(item.exposeTime!=''){//系统揭发时间
						mating_status+='<div class="liebiao-aa"><p class="liebiao-l">揭发时间</p><p class="liebiao-r">' +
								item.exposeTime+
								'</p><div class="clear"></div></div>';
					}
					if(flag == 1 || flag == 2 || flag == 4) {
					if(item.exposeTime!=''){
						mating_status+='<div class="liebiao-aa"><p class="liebiao-l" >最佳配种时间</p><p class="liebiao-r" >' + dateTest1(item.exposeTime)+'点~'+dateTest(item.exposeTime)+'点'+
                '</p><div class="clear"></div></div>';
					}
					}
					if (item.Last_mating!=undefined){
						mating_status+='<div class="liebiao-aa"><p class="liebiao-l">上次配种时间</p><p class="liebiao-r">' +
								item.Last_mating+
								'</p><div class="clear"></div></div>';
					}
					if (item.Last_mating_date!=undefined){
						mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">配后天数</p><p class="liebiao-r">' +
								item.Last_mating_date+
								'天</p><div class="clear"></div></div>';
					}
					mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">泌乳天数</p><p class="liebiao-r">' +
							item.lactationDate+
							'天</p><div class="clear"></div></div>';
					mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">胎次</p><p class="liebiao-r">' +
							item.parity+
							'次</p><div class="clear"></div></div>';
					mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">配次</p><p class="liebiao-r">' +
							item.allocation+
							'次</p><div class="clear"></div></div>';
					if (item.reproductive_status!=undefined){
						mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">繁殖状态</p><p class="liebiao-r">' +
								item.reproductive_status+
								'</p><div class="clear"></div></div>';//上次配种时间和繁殖状态		
					}
					// mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">奶量</p><p class="liebiao-r">' +
					// 		item.milk+
					// 		'kg</p><div class="clear"></div></div>';
					mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">奶量班次1</p><p class="liebiao-r">' +
							item.milk1+
							'kg</p><div class="clear"></div></div>';
					mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">奶量班次2</p><p class="liebiao-r">' +
							item.milk2+
							'kg</p><div class="clear"></div></div>';
					mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">奶量班次3</p><p class="liebiao-r">' +
							item.milk3+
							'kg</p><div class="clear"></div></div>';
					if(item.real_name!=undefined&&item.real_name!=""){
						mating_status+= '</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">判定人</p><p class="liebiao-r">' +
								item.real_name+
								'</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">操作时间</p><p class="liebiao-r">' +
								item.statetime+
								'</p><div class="clear"></div></div>';
					}
					if (item.ce_actual_breeding!=undefined){//配种状态或未配种原因
						if (item.ce_actual_breeding=='常规冻精'||item.ce_actual_breeding=='性控冻精'){
							mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">配种</p><p class="liebiao-r">' +
												item.ce_actual_breeding+
											'</p><div class="clear"></div></div>';
						} else{
							var  reson="未配原因";
							if (item.result=="确认未发情") {
								reson='未发情原因';
							}
							mating_status+=	'<div class="liebiao-aa"><p class="liebiao-l">'+reson+'</p><p class="liebiao-r">' +
									item.ce_actual_breeding+
									'</p><div class="clear"></div></div>';
						}
					}
					if(item.rut == 1) {
						var div = '<div id="0' + i + '" onclick="OestrusDetails(this.id)"><img class="liebiao-que-l" src="images/banyuan@3x.png" /><img class="liebiao-que-r" src="images/banyuan-right@3x.png" /><div class="xulieh-div"><p class="xulie-p">' +
							item.deviceNumber +
							'</p><p class="biaoqian-b">' +
							item.conceive +
							'</p></div><div><div class="liebiao-aa"><p class="liebiao-l">奶牛耳号</p><p class="liebiao-r">' +
							item.overbit +
							'</p><div class="clear"></div></div>'+mating_status+'<div class="liebiao-aa"><p class="liebiao-l">类型</p><p class="liebiao-r">' +
							item.cowType +
							'</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">牛舍</p><p class="liebiao-r">' +
							item.cowHouseName +
							'</p><div class="clear"></div></div></div></div><div class="fqpd"><div class="fqpd-ss"><p id="' + i +
							'" onclick="OestrusDetermination(this.id)">' +
							item.result +
							'</p></div><div class="fqpd-ss"><div class="fengx"></div><p id="'+ i+'" onclick="ranchingActivities(this.id)">牧场调整</p></div><div class="clear"></div></div><div style="height:12px;	background: #F0F0F0;"></div>'
							//找牛按钮
							//'</p></div><div class="fqpd-ss"><div class="fengx"></div><p id="s' + item.cow_id +'" style="padding: 0;border: none;font-size: 14px;color: #2d82ff;margin-bottom: 0px;line-height: 28px;">找牛</p></div><div class="clear"></div></div><div style="height:12px;	background: #F0F0F0;"></div>'
							
					} else {
						var div = '<div id="0' + i + '" onclick="OestrusDetails(this.id)"><img class="liebiao-que-l" src="images/banyuan@3x.png" /><img class="liebiao-que-r" src="images/banyuan-right@3x.png" /><div class="xulieh-div"><p class="xulie-p">' +
							item.deviceNumber +
							'</p><p class="biaoqian-b">' +
							item.conceive +
							'</p></div><div><div class="liebiao-aa"><p class="liebiao-l">奶牛耳号</p><p class="liebiao-r">' +
							item.overbit +
							'</p><div class="clear"></div></div>'+mating_status+'<div class="liebiao-aa"><p class="liebiao-l">类型</p><p class="liebiao-r">' +
							item.cowType +
							'</p><div class="clear"></div></div><div class="liebiao-aa"><p class="liebiao-l">牛舍</p><p class="liebiao-r">' +
							item.cowHouseName +
							'</p><div class="clear"></div></div></div></div><div class="fqpd"><div class="fqpd-ss"><p id="' + i +
							'" onclick="OestrusDetermination(this.id)">' +
							item.result +
							//'</p></div><div class="fqpd-ss"><div class="fengx"></div><p onclick="WPReason(5)">牧场活动</p></div><div class="clear"></div></div><div style="height:12px;	background: #F0F0F0;"></div>'
									//找牛按钮
									 '</p></div><div class="fqpd-ss"><div class="fengx"></div><p id="s' + item.cow_id +
									'"  data-options=\'{"beginYear":' +
									parseInt(item.AllowLightTime.substr(0, 4)) +
									',"beginMonth":' +
									parseInt(item.AllowLightTime.substr(5, 2)) +
									',"beginDay":' +
									parseInt(item.AllowLightTime.substr(8, 2)) +
									',"beginHours":' +
									parseInt(item.AllowLightTime.substr(11, 2)) +
									'}\' class="btn mui-btn mui-btn-block" style="padding: 0;border: none;font-size: 14px;color: #2d82ff;margin-bottom: 0px;line-height: 28px;">找牛</p></div><div class="clear"></div></div><div style="height:12px;	background: #F0F0F0;"></div>' 
							}
					return div
				}

				function getnoApplicationData() {
					var html = ''
					for(var i = 0; i < DetailsOfOestrusData.length; i++) {
						//					DetailsOfOestrusData[i]["AllowLightTime"] = "2018-09-25 23:15:09";
						html += setDiv(DetailsOfOestrusData[i], i)
					}
					tableCellID.innerHTML = html
				}
			function huitu() {
				window.onload = getnoApplicationData()
			}
			function findsearchCow(){
				butStr = 0;
				pageNumber = 2;
				var overbit=document.getElementById("searchData").value;			
				if(overbit=="请输入奶牛耳号"){
					overbit="";
				}
				var map={};
				map.overbit=overbit;
				searchCow(map);
			}
			function searchCow(map){										
				var type = JSON.parse(localStorage.getItem('DetailsType'));
				var keys = JSON.parse(localStorage.getItem('key'));
				var mapdate = JSON.parse(localStorage.getItem('paramsNameDate'));
				if(map==undefined){
					var map = {};
				}
				map.key = keys;
				map.page = 1;
				map.size = 20;
				if(type == 1 || type == 2 || type == 3||type==11) {
					var paramsName = JSON.parse(localStorage.getItem('paramsNameDate'));
					map.startDate = paramsName;
					map.endDate = paramsName;
				}
				map.date=mapdate;
				map.type = type;
				map.phoneType = "android";
				map.language = "zh";
				var jsonStr = JSON.stringify(map);
				console.log(jsonStr);
				showDialog();
				var ajaxTimeoutTest = $.ajax({
					type: "POST",
					url: url_prefix + "estrusList",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						dismissDialog();
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							if(bb.data.length != 20) {
								butStr = 1;
							}
							if(bb.data.length == 0) {
								mui.toast("没有更多数据了");
							}
							localStorage.setItem('DetailsOfOestrusData', JSON.stringify(bb.data));
							DetailsOfOestrusData = JSON.parse(localStorage.getItem('DetailsOfOestrusData'));
							huitu();
						} else {
							mui.alert(bb.head.info);
						}
					},
					complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
						dismissDialog();
						if(status == 'timeout') { //超时,status还有success,error等值的情况
							ajaxTimeoutTest.abort();　　　　　
							mui.alert("网络请求超时...");　　　　
						}　　
					}
				});
			}
			/*隐藏发情*/
			function hideysfaq(){
				document.body.style.cssText = 'overflow:auto';
				for (i=0;i<=6;i++){
					var lup="lu_pan"+i;
					var weifaq=document.getElementById(lup);
					weifaq.style.display="none";
				}
			}
			//3判定未发情
			function HeadOestrusInterface(result) {
				var map = {};
				map.result = result;//判定未发情
				OestrusInterface(map)
			}
			function HeadOestrusInterface1(result) {
				var parmID=JSON.parse(localStorage.getItem("parmID"));
				if(result == 6){
					if(parmID == 5){
						var map = {};
						map.result = 0;
						map.breeding = $("#iptext1").val();
						OestrusInterface(map)
					}else if(parmID == 1){
						var map = {};
						map.result = 2;
						map.breeding = $("#iptext1").val();
						OestrusInterface(map)
					}else{
						var map = {};
						map.result = 3;
						map.breeding = $("#iptext1").val();
						OestrusInterface(map)
					}
					
				}else{
					var strlu=JSON.parse(localStorage.getItem("parmlu"));
					if (strlu=="4") {//判定发情未配种
						var map = {};
						map.result = result;
						map.breeding = $("#iptext1").val();
						OestrusInterface(map)
					}
					if (strlu=="5") {//判定为未发情原因
						var map = {};
						map.result = 3;
						map.breeding = $("#iptext1").val();
						OestrusInterface(map)
					}
				}
				
			}
			//判定发情加配种情况
			function HeadOestrusInterface2(obj) {
				var map = {};
				map.result =2;//判定未发情
				map.breeding=obj.innerHTML;
				OestrusInterface(map)
			}
			/*判定发情情况*/
			function OestrusInterface(map) {
				if (map==undefined){
					var map = {};
				}
				var id=document.getElementById("lu_pan_y").attributes["cow_id"].nodeValue;
				var cow_id=DetailsOfOestrusData[id].cow_id;
				var keys = JSON.parse(localStorage.getItem('key'));
				var paramsName =DetailsOfOestrusData[id].ce_date;
				map.key = keys;
				map.cowID = cow_id;
//				map.remark = remark.value;
				map.date = paramsName;
				map.phoneType = "android";
				map.language = "zh";
				console.log(map);
				var jsonStr = JSON.stringify(map);
				showDialog();
				var ajaxTimeoutTest = $.ajax({
					type: "POST",
					url: url_prefix + "estrusDetermination",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						dismissDialog();
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							hideysfaq();
							tjOestrus();
							mui.alert("操作成功");
						} else {
							mui.alert(bb.head.info);
						}
					},
					complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
						dismissDialog();
						if(status == 'timeout') { //超时,status还有success,error等值的情况
							ajaxTimeoutTest.abort();
							mui.alert("网络请求超时...");
						}
					}
				});
			}
			function ranchingActivities(id){
				document.getElementById("lu_pan_ob").innerHTML=DetailsOfOestrusData[id].overbit+"判定揭发情况";
				document.getElementById("lu_pan_ob1").innerHTML=DetailsOfOestrusData[id].overbit+"配种情况";
				document.getElementById("lu_pan_ob2").innerHTML=DetailsOfOestrusData[id].overbit+"配种精子选择";
				document.getElementById("lu_pan_ob3").innerHTML=DetailsOfOestrusData[id].overbit+"操作原因";
				document.getElementById("lu_pan_y").setAttribute("cow_id",id);
				WPReason(5);
			}
			//未配种和未发情原因
			function WPReason(parm) {
				localStorage.setItem('parmID',JSON.stringify(parm));
			    var type=parm;
			    var reason='未配种原因';
			    if (parm==1){
			        type=4;//发情未配原因
                }
			    if (parm==2){//未发情原因
			        type=5;
					reason='未发情原因';
                }
                localStorage.setItem('parmlu',JSON.stringify(type));
				var keys = JSON.parse(localStorage.getItem('key'));
				var map = {};
				map.key = keys;
				map.phoneType = "android";
				map.language = "zh";
				map.ResonType=parm;
				var jsonStr = JSON.stringify(map);
				showDialog();
				var ajaxTimeoutTest = $.ajax({
					type: "POST",
					url: url_prefix + "wpReason",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						dismissDialog();
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							var  wpdata=bb.data;
							$("#lu_pan4").html("");
							var head='<div class="head-zhjf">'
										+'<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="hideysfaq()" >'
										+'<p style="color: white;">'+reason+'</p>'
									+'</div>';
							$("#lu_pan4").append(head);
							for (i=0;i<wpdata.length;i++) {
								var str='<div class="moban-lb">'
											+'<div class="moban-lb-l" style="width: 100%">'
											+'<a class="ziduan-mb" onclick="hideYuanYing(this)">'+wpdata[i].unmatch+'</a>'
										+'</div>';
								$("#lu_pan4").append(str);
							}
							var weifaq=document.getElementById("lu_pan4");
							weifaq.style.display="block";
						} else {
							mui.alert(bb.head.info);
						}
					},
					complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
						dismissDialog();
						if(status == 'timeout') { //超时,status还有success,error等值的情况
							ajaxTimeoutTest.abort();
							mui.alert("网络请求超时...");
						}
					}
				});
			}
			//1.显示配种情况弹框  1,选择精子类型状态 3.未配弹框
			function ShowTangKang(parm) {
				document.body.style.cssText = 'overflow:hidden';
				localStorage.setItem('parmlu',JSON.stringify(parm));
				var str="lu_pan"+parm;
				var weifaq=document.getElementById(str);
				weifaq.style.display="block";
			}
			function ShowTangKang3() {
				document.body.style.cssText = 'overflow:hidden';
				var str="lu_pan"+3;
				var weifaq=document.getElementById(str);
				weifaq.style.display="block";
			}
			//返回未配弹框
			function hideYuanYing(obj) {
				document.body.style.cssText = 'overflow:auto';
				$("#iptext1").val(obj.innerHTML);
				hideysfaq();
				ShowTangKang3();
			}
		</script>
	</body>

</html>